
import React from 'react';
import  {Component} from 'react';
import { Table, Tag ,PageHeader} from 'antd';
import './index.scss'
import {
  getServerInfo
} from '../../services/docapi';

class InfoList extends Component {

    constructor(props) {
        super(props);
        this.getDocDbList();
        this.state = {
            columns : [
                {
                  title: 'pipeline',
                  dataIndex: 'pipeline',
                  key: 'pipeline',
                  render: text => <a>{text}</a>,
                },
                {
                  title: 'instance',
                  dataIndex: 'instance',
                  key: 'instance',
                },
              ],
              
            data : []

        };
    }

        // 获取info
      getDocDbList = async () => {
          try {
            const raw = await getServerInfo();
            const raw_result = raw.data.stateMap.route_info;
            const real_reasult = {};
            for(var x in raw_result){
              real_reasult[x]=raw_result[x].join(";");
            }
            var index=1;
            var pagedata=[];
            for(var y in real_reasult){
              pagedata.push({
                key: index.toString(),
                pipeline: y,
                instance: real_reasult[y],
              })
            }
            this.setState({
              data:pagedata
            })
            

            console.log(real_reasult);
          } catch (error) {
            console.log(error)
          }finally{
          }
      }

    render() {
        const {
            columns,
            data
        } = this.state;
        return (
            <div>
                <PageHeader
                className="site-page-header"
                onBack={() => null}
                title="实例列表"
                />,
                <Table columns={columns} dataSource={data} />
            </div>
        );
    }
}


export default InfoList;